package com.ideapse.springcloud.controller;

import com.ideapse.springcloud.client.DeptConsumerClient;
import com.ideapse.springcloud.client.DeptConsumerFeignClient;
import com.ideapse.springcloud.pojo.Dept;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author LuoJianWei
 * @email LuoJianWei_98@foxmail.com
 * @date 2024/4/27 19:47
 */
@RestController
@RequestMapping("/dept")
public class DeptConsumerController {

    @Autowired
    DeptConsumerClient deptConsumerClient;

    @Autowired
    DeptConsumerFeignClient deptConsumerFeignClient;

    @PostMapping
    public boolean addDept(@RequestBody Dept dept){
        return deptConsumerFeignClient.addDept(dept);
    }

    @GetMapping("/{id}")
    public Dept getDeptById(@PathVariable("id") Long id){
        return deptConsumerFeignClient.getDeptById(id);
    }

    @GetMapping("/all")
    public List<Dept> getAll(){
        return deptConsumerFeignClient.getAll();
    }

}
